package P5;

import P1.Demo;
import P2.Config;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class TestCase {
    AnnotationConfigApplicationContext ctx;

    @Before
    public void init(){
        ctx=new AnnotationConfigApplicationContext(Config.class);
        System.out.println("初始化spring");
    }
    @After
    public void destroy(){
        ctx.close();
        System.out.println("销毁spring");
    }
    @Test
    public void testBean(){
        Demo demo=ctx.getBean("bean", Demo.class);
        System.out.println(demo);
    }
    @Test
    public void test(){
        System.out.println("Hello World");
    }
    @Test
    public void testDemoBean(){
        DemoBean bean=ctx.getBean("demoBean",DemoBean.class);
        System.out.println(bean);

    }
}
